﻿CREATE TRIGGER [dbo].[TR_Folder_Delete]
	ON [dbo].[Folder]
	AFTER DELETE
	AS
	BEGIN
		SET NOCOUNT ON
		-- Delete all subfolders
		MERGE [dbo].[Folder] AS T
		USING DELETED AS S
		ON T.[ParentFolderId] = S.[Id]
		WHEN MATCHED THEN DELETE;
	END